package org.boyan.modules.service.impl;

import org.boyan.entity.cases.Case;
import org.boyan.modules.mapper.CaseMapper;
import org.boyan.modules.service.CaseService;
import org.boyan.modules.vo.CaseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CaseServiceImpl implements CaseService {
    @Autowired
    private CaseMapper caseMapper;

    @Override
    public boolean addCase(Case caseEntity) {
        boolean caseFlag=caseMapper.addCase(caseEntity)==1;
        return caseFlag;
    }

    @Override
    public List<CaseVo> getCaseVoList(int current, int size, Case caseCriteria) {
        int currentPage=(current-1)*size;
        return caseMapper.getCaseVoList(currentPage,size,caseCriteria);
    }

    @Override
    public int getTotalByCriteria(Case caseCriteria) {
        return caseMapper.getTotalByCriteria(caseCriteria);
    }

    @Override
    public Case getCaseInfoById(String id) {
        return caseMapper.getCaseInfoById(id);
    }

    @Override
    public boolean editCase(Case caseInfo) {
        return caseMapper.editCase(caseInfo)==1;
    }

    @Override
    public boolean auditCase(String id) {
        return caseMapper.changeCaseStatus(3,id)==1;
    }

    @Override
    public boolean returnCase(String id) {
        return caseMapper.changeCaseStatus(1,id)==1;
    }

    @Override
    public boolean deleteCase(String id) {
        return caseMapper.deleteCase(id)==1;
    }

    @Override
    public boolean changeCaseStatus(int caseStatus, String id) {
        return caseMapper.changeCaseStatus(caseStatus,id)==1;
    }

    @Override
    public boolean allocateCaseByCaseId(String developPrincipal, String caseId) {
        return caseMapper.allocateCaseByCaseId(developPrincipal, caseId)==1;
    }
}
